﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;

namespace PW_kalendarz
{
    class Mailer
    {
        public static void sendMail(String sendTo, String subject, String message)
        {
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

            mail.From = new MailAddress("kontotestowex@gmail.com");
            mail.To.Add(sendTo);
            mail.Subject = subject;
            mail.Body = message;

            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential("kontotestowex", "haslotest");
            SmtpServer.EnableSsl = true;

            SmtpServer.Send(mail);
        }

        public static void sendMails(List<String> mails, String subject, String message)
        {
            foreach (String mail in mails)
            {
                sendMail(mail, subject, message); 
            }
        }
    }
}
